package com.ruoyi.common.utils;


import com.ruoyi.common.core.domain.entity.RepUser;

/**
 * @author cpf
 * @date 2024/1/29 14:31
 * @description 存放当前线程的用户信息
 */
public class ThreadLocalUtils {


    public static ThreadLocal<RepUser> userThreadLocal = new ThreadLocal<>();


    /**
     * 从ThreadLocal中获取用户信息
     * @return  ShopUser
     */
    public RepUser get(){
        return userThreadLocal.get();
    }

    /**
     * 添加用户信息到ThreadLocal
     * @param shopUser 用户信息
     */
    public void set(RepUser repUser){
        userThreadLocal.set(repUser);
    }


    /**
     * 删除ThreadLocal存放的信息
     */
    public void remove(){
        userThreadLocal.remove();
    }


}
